package com.wsseieiei.fireballgame;

import com.wsseieiei.fireballgame.init.*;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.jetbrains.annotations.NotNull;

import static com.wsseieiei.fireballgame.init.StruInit.MY_ORE;

//这里填上你的模组名称modid
@Mod("fireballgame")
public class Main {

    public static final String MOD_ID = "fireballgame";
    public static final CreativeModeTab FIREBALL_GAME_TAB = new CreativeModeTab(MOD_ID) {
        @Override
        @OnlyIn(Dist.CLIENT)
        public @NotNull ItemStack makeIcon() {
            return new ItemStack(ItemInit.BALL.get());
        }
    };

    public Main() {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        //添加物品，方块的初始化信息
        ItemInit.ITEMS.register(bus);
        BlockInit.BLOCKS.register(bus);
        EntityInit.ENTITY_TYPES.register(bus);
        EffectInit.EFFECTS.register(bus);
        PotionInit.POTIONS.register(bus);
        MinecraftForge.EVENT_BUS.register(this);

        FMLJavaModLoadingContext.get().getModEventBus().addListener(Main::setup);
        MinecraftForge.EVENT_BUS.addListener(Main::biomeLoading);

        BlockEntityInit.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BlockEntityInit.BLOCK_ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
        BlockEntityInit.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
    }
    public static void setup(FMLCommonSetupEvent event) {
        IEventBus bus = MinecraftForge.EVENT_BUS;
        event.enqueueWork(StruInit::registerFeatures);
    }
    public static void biomeLoading(BiomeLoadingEvent event) {
        event.getGeneration().addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, MY_ORE);
    }
}